package cn.com.utt.common.message;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;

public class Set extends Message {

	@JSONField(name="replyto") 
	private String replyTo;
	@JSONField(name="data") 
	private Object data;
	@JSONField(name = "commit")
	private boolean commit;
	
	public Set(){
		setType(MessageType.SET.toString());
	}

	@Override
	public String encode() {
		return JSON.toJSONString(this);
	}

	@Override
	public void decode(byte[] buf){
		Set set = JSON.parseObject(buf, Set.class);
		this.setId(set.getId());
		this.replyTo = set.getReplyTo();
		this.data  = set.getData();
		this.commit = set.isCommit();
	}

	public String getReplyTo() {
		return replyTo;
	}

	public void setReplyTo(String replyTo) {
		this.replyTo = replyTo;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public boolean isCommit() {
		return commit;
	}

	public void setCommit(boolean commit) {
		this.commit = commit;
	}
}
